<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('BPO工作量统计列表')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li class="select-time">
                                <p>工作日期：</p>
                                <input type="text" class="time-input" id="beginWorkDate" placeholder="必填" name="beginWorkDate" required/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endWorkDate" placeholder="选填" name="endWorkDate"/>
                            </li>
                            <li>
                                <p>操作员号：</p>
                                <input type="text" name="userCode"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="tableSearch()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                <a class="btn btn-warning" onclick="exportData()" shiro:hasPermission="stat:workload:export">
                                    <i class="fa fa-download"></i> 导出
                                </a>
                            </li>
                            <li>
                                <p>机构号：</p>
                                <input type="text" onclick="selectDeptTree()" placeholder="请选择"  id="treeId" name="orgCode"/>
                            </li>
                            <li>
                                <p>工作类型：</p>
                                <select name="workType" id="workType" th:with="type=${workloadType}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.value}" th:value="${dict.key}"></option>
                                </select>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div id="_tableDiv" class="col-sm-12 select-table table-striped table table-bordered table-condensed">
                <table id="bootstrap-table" style="white-space:nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: ztree-js" />
    <script th:inline="javascript">
        var prefix = ctx + "stat/workload";
        var firstTitle = "扫描补录员工作量统计表";
        var deptMap = [[${deptMap}]];
        var defaultOrg = [[${defaultOrg}]];
        //表头设置
        var _head1colspan1=33;
        var _head2rowspan=3;var _head2colspan1=3;var _head2colspan2=6;
        var _head3colspan = 2;
        //第一行表头
        var firstHeadColumns = [{title : firstTitle,align : 'center',colspan : _head1colspan1}];
        //第二行表头
        var secondHeadColumns = [{title : '监控中心号',align : 'center',field : 'organCode',rowspan : _head2rowspan},
            {title : '监控中心名称',align : 'center',field : 'organName',rowspan : _head2rowspan},
            {title : '操作员',align : 'center',field : 'userCode',rowspan : _head2rowspan,
                formatter: function (value, row, index) {
                    if((row.userCode+"-"+row.userName)=='小计-:'){return "小计:"}
                    else if((row.userCode+"-"+row.userName)=='合计-:'){return "合计:"}
                    else {return (row.userCode+"-"+row.userName)}
                }},
            {title : '扫描量',align : 'center',colspan : _head2colspan2},
            {title : '人工补录量',align : 'center',colspan : _head2colspan2},
            {title : '二次补录量',align : 'center',colspan : _head2colspan2},
            {title : '打包量',align : 'center',colspan : _head2colspan1},
            {title : '入箱量',align : 'center',colspan : _head2colspan1},
            {title : '补录量汇总',align : 'center',colspan : _head2colspan2}];
        //第三行
        var head3Columns = [];
        for (var i=0;i<3; i++)
        {
            head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
            head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
            head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
        }
        _head3colspan = 1;
        for (var i=0;i<2; i++)
        {
            head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
            head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
            head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
        }
        _head3colspan = 2;
        head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
        head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
        head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
        //第四行数据
        //扫描量
        var scanYearBatchNum = {title : '批次数',align : 'center',field:'scanYearBatchNum'};
        var scanYearWorkload ={title : '凭证张数',align : 'center',field:'scanYearWorkload'};
        var scanMonthBatchNum = {title : '批次数',align : 'center',field:'scanMonthBatchNum'};
        var scanMonthWorkload = {title : '凭证张数',align : 'center',field:'scanMonthWorkload'};
        var scanDayBatchNum = {title : '批次数',align : 'center',field:'scanDayBatchNum'};
        var scanDayWorkload = {title : '凭证张数',align : 'center',field:'scanDayWorkload'};
        //人工补录量
        var inputYearBatchNum = {title : '批次数', align : 'center',field:'inputYearBatchNum'};
        var inputYearWorkload = {title : '凭证张数',align : 'center',field:'inputYearWorkload'};
        var inputMonthBatchNum = {title : '批次数',align : 'center',field:'inputMonthBatchNum'};
        var inputMonthWorkload = {title : '凭证张数',align : 'center',field:'inputMonthWorkload'};
        var inputDayBatchNum = {title : '批次数',align : 'center',field:'inputDayBatchNum'};
        var inputDayWorkload = {title : '凭证张数',align : 'center',field:'inputDayWorkload'};
        //二次补录量
        var forceInputYearBatchNum = {title : '批次数',align : 'center',field:'forceInputYearBatchNum'};
        var forceInputYearWorkload = {title : '凭证张数',align : 'center',field:'forceInputYearWorkload'};
        var forceInputMonthBatchNum = {title : '批次数',align : 'center',field:'forceInputMonthBatchNum'};
        var forceInputMonthWorkload = {title : '凭证张数',align : 'center',field:'forceInputMonthWorkload'};
        var forceInputDayBatchNum = {title : '批次数',align : 'center',field:'forceInputDayBatchNum'};
        var forceInputDayWorkload = {title : '凭证张数',align : 'center',field:'forceInputDayWorkload'};
        //打包量
        var packedYearWorkload = {title : '总数', align : 'center', field:'packedYearWorkload'};
        var packedMonthWorkload = {title : '总数', align : 'center', field:'packedMonthWorkload'};
        var packedDayWorkload = {title : '总数', align : 'center', field:'packedDayWorkload'};
        //入箱量
        var inBoxYearWorkload = {title : '总数', align : 'center', field:'inBoxYearWorkload'};
        var inBoxMonthWorkload = {title : '总数', align : 'center', field:'inBoxMonthWorkload'};
        var inBoxDayWorkload = {title : '总数', align : 'center', field:'inBoxDayWorkload'};
        //补录量汇总
        var totalYearBatchNum = {title : '批次数', align : 'center',field:'totalYearBatchNum',
            formatter: function (value, row, index) {var count=0;
            for(prop in row){if(prop=='inputYearBatchNum'||prop=='forceInputYearBatchNum'){count += parseInt(row[prop]);}} row.totalYearBatchNum=count; return count;}
            };
        var totalYearWorkload = {title : '凭证张数', align : 'center',field:'totalYearWorkload',
            formatter: function (value, row, index) {var count=0;
                for(prop in row){if(prop=='inputYearWorkload'||prop=='forceInputYearWorkload'){count += parseInt(row[prop]);}} row.totalYearWorkload=count; return count;}
            };
        var totalMonthBatchNum = {title : '批次数', align : 'center',field:'totalMonthBatchNum',
            formatter: function (value, row, index) {var count=0;
                for(prop in row){if(prop=='inputMonthBatchNum'||prop=='forceInputMonthBatchNum'){count += parseInt(row[prop]);}} row.totalMonthBatchNum=count; return count;}
            };
        var totalMonthWorkload = {title : '凭证张数', align : 'center',field:'totalMonthWorkload',
            formatter: function (value, row, index) {var count=0;
                for(prop in row){if(prop=='inputMonthWorkload'||prop=='forceInputMonthWorkload'){count += parseInt(row[prop]);}} row.totalMonthWorkload=count; return count;}
            };
        var totalDayBatchNum = {title : '批次数', align : 'center',field:'totalDayBatchNum',
            formatter: function (value, row, index) {var count=0;
                for(prop in row){if(prop=='inputDayBatchNum'||prop=='forceInputDayBatchNum'){count += parseInt(row[prop]);}} row.totalDayBatchNum=count; return count;}
            };
        var totalDayWorkload = {title : '凭证张数', align : 'center',field:'totalDayWorkload',
            formatter: function (value, row, index) {var count=0;
                for(prop in row){if(prop=='inputDayWorkload'||prop=='forceInputDayWorkload'){count += parseInt(row[prop]);}} row.totalDayWorkload=count;return count;}
            };
        var head4Columns = [
            //扫描量
            scanYearBatchNum,scanYearWorkload, scanMonthBatchNum,scanMonthWorkload,scanDayBatchNum,scanDayWorkload,
            //人工补录量
            inputYearBatchNum,inputYearWorkload,inputMonthBatchNum,inputMonthWorkload,inputDayBatchNum,inputDayWorkload,
            //二次补录量
            forceInputYearBatchNum,forceInputYearWorkload,forceInputMonthBatchNum,forceInputMonthWorkload,forceInputDayBatchNum,forceInputDayWorkload,
            //打包量
            packedYearWorkload,packedMonthWorkload,packedDayWorkload,
            //入箱量
            inBoxYearWorkload,inBoxMonthWorkload,inBoxDayWorkload,
            //补录量汇总
            totalYearBatchNum,totalYearWorkload,totalMonthBatchNum,totalMonthWorkload,totalDayBatchNum,totalDayWorkload
        ];
        //表头汇总
        var headColumns = [
            firstHeadColumns,
            secondHeadColumns,
            head3Columns,
            head4Columns
           ];
        //参数
        var options = {
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            showExport:false,
            clickToSelect:true,
            singleSelect:true,
            rowStyle:_rowStyle,
            //fixedColumns: true,
            //fixedNumber: 3,
            exportUrl: prefix + "/export",
            modalName: "BPO工作量统计",
            pagination:false,
            columns:headColumns
        };
        //初始化
        $(function() {$.table.init(options);});
        //查询
        function tableSearch(){
            if(!$.validate.form()){
                return;
            }
            //设置表头
            firstTitle = "扫描补录员工作量统计表";
            var titleOrgCode = $("#treeId").val();
            if(titleOrgCode==null||titleOrgCode==''){
                titleOrgCode = defaultOrg;
            }
            var titleOrgName = deptMap[titleOrgCode];
            titleOrgName = (titleOrgName==null||titleOrgName=='')?"":titleOrgName;
            if(($("#endWorkDate").val()=='')){
                $("#endWorkDate").val($("#beginWorkDate").val());
                firstTitle = $("#beginWorkDate").val()+firstTitle;
            }else{
                firstTitle = $("#beginWorkDate").val()+"至"+$("#endWorkDate").val()+firstTitle;
            }
            firstTitle = titleOrgName+"("+titleOrgCode+")"+firstTitle;
            //根据条件动态设置表头
            var workType = $('#workType option:selected').val();
            secondHeadColumns = [];
            head3Columns = [];
            head4Columns = [];
            if(workType == ''){
                if($("#endWorkDate").val()>$("#beginWorkDate").val()){
                    //根据日期查询无本年本月_head2rowspan=2,无head3Columns,head4Columns无年月统计
                    _head1colspan1=13;
                    _head2rowspan=2;
                    _head2colspan1=1;
                    _head2colspan2=2;
                    head4Columns = [
                        //扫描量
                        scanDayBatchNum,scanDayWorkload,
                        //人工补录量
                        inputDayBatchNum,inputDayWorkload,
                        //二次补录量
                        forceInputDayBatchNum,forceInputDayWorkload,
                        //打包量
                        packedDayWorkload,
                        //入箱量
                        inBoxDayWorkload,
                        //补录量汇总
                        totalDayBatchNum,totalDayWorkload
                    ];
                }else{
                    _head1colspan1=33;
                    _head2rowspan=3;_head2colspan1=3;_head2colspan2=6;
                    _head3colspan = 2;
                    //第三行
                    for (var i=0;i<3; i++)
                    {
                        head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
                        head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
                        head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
                    }
                    _head3colspan = 1;
                    for (var i=0;i<2; i++)
                    {
                        head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
                        head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
                        head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
                    }
                    _head3colspan = 2;
                    head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
                    head4Columns = [
                        //扫描量
                        scanYearBatchNum,scanYearWorkload, scanMonthBatchNum,scanMonthWorkload,scanDayBatchNum,scanDayWorkload,
                        //人工补录量
                        inputYearBatchNum,inputYearWorkload,inputMonthBatchNum,inputMonthWorkload,inputDayBatchNum,inputDayWorkload,
                        //二次补录量
                        forceInputYearBatchNum,forceInputYearWorkload,forceInputMonthBatchNum,forceInputMonthWorkload,forceInputDayBatchNum,forceInputDayWorkload,
                        //打包量
                        packedYearWorkload,packedMonthWorkload,packedDayWorkload,
                        //入箱量
                        inBoxYearWorkload,inBoxMonthWorkload,inBoxDayWorkload,
                        //补录量汇总
                        totalYearBatchNum,totalYearWorkload,totalMonthBatchNum,totalMonthWorkload,totalDayBatchNum,totalDayWorkload
                    ];
                }
                secondHeadColumns = [{title : '监控中心号',align : 'center',field : 'organCode',rowspan : _head2rowspan},
                    {title : '监控中心名称',align : 'center',field : 'organName',rowspan : _head2rowspan},
                    {title : '操作员',align : 'center',field : 'userCode',rowspan : _head2rowspan,
                        formatter: function (value, row, index) {
                            if((row.userCode+"-"+row.userName)=='小计-:'){return "小计:"}
                            else if((row.userCode+"-"+row.userName)=='合计-:'){return "合计:"}
                            else {return (row.userCode+"-"+row.userName)}
                        }},
                    {title : '扫描量',align : 'center',colspan : _head2colspan2},
                    {title : '人工补录量',align : 'center',colspan : _head2colspan2},
                    {title : '二次补录量',align : 'center',colspan : _head2colspan2},
                    {title : '打包量',align : 'center',colspan : _head2colspan1},
                    {title : '入箱量',align : 'center',colspan : _head2colspan1},
                    {title : '补录量汇总',align : 'center',colspan : _head2colspan2}];
            }else if(workType=='1-SCAN'){
                if($("#endWorkDate").val()>$("#beginWorkDate").val()){
                    _head1colspan1=5;
                    _head2rowspan=2;
                    _head2colspan1=1;
                    _head2colspan2=2;
                    head4Columns.push(scanDayBatchNum,scanDayWorkload);
                }else{
                    _head1colspan1=9;
                    _head2rowspan=3;
                    _head2colspan1=3;
                    _head2colspan2=6;
                    _head3colspan = 2;
                    //第三行
                    head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
                    head4Columns.push(scanYearBatchNum,scanYearWorkload, scanMonthBatchNum,scanMonthWorkload,scanDayBatchNum,scanDayWorkload);
                }
                secondHeadColumns.push({title : '监控中心号',align : 'center',field : 'organCode',rowspan : _head2rowspan},
                    {title : '监控中心名称',align : 'center',field : 'organName',rowspan : _head2rowspan},
                    {title : '操作员',align : 'center',field : 'userCode',rowspan : _head2rowspan,
                        formatter: function (value, row, index) {
                            if((row.userCode+"-"+row.userName)=='小计-:'){return "小计:"}
                            else if((row.userCode+"-"+row.userName)=='合计-:'){return "合计:"}
                            else {return (row.userCode+"-"+row.userName)}
                        }},
                    {title : '扫描量',align : 'center',colspan : _head2colspan2});
            }else if(workType=='4-ManualInput') {
                if($("#endWorkDate").val()>$("#beginWorkDate").val()){
                    _head1colspan1=5;
                    _head2rowspan=2;
                    _head2colspan1=1;
                    _head2colspan2=2;
                    head4Columns.push(inputDayBatchNum,inputDayWorkload);
                }else{
                    _head1colspan1=9;
                    _head2rowspan=3;
                    _head2colspan1=3;
                    _head2colspan2=6;
                    _head3colspan = 2;
                    head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
                    head4Columns.push(inputYearBatchNum,inputYearWorkload,inputMonthBatchNum,inputMonthWorkload,inputDayBatchNum,inputDayWorkload);
                }
                secondHeadColumns.push({title : '监控中心号',align : 'center',field : 'organCode',rowspan : _head2rowspan},
                    {title : '监控中心名称',align : 'center',field : 'organName',rowspan : _head2rowspan},
                    {title : '操作员',align : 'center',field : 'userCode',rowspan : _head2rowspan,
                        formatter: function (value, row, index) {
                            if((row.userCode+"-"+row.userName)=='小计-:'){return "小计:"}
                            else if((row.userCode+"-"+row.userName)=='合计-:'){return "合计:"}
                            else {return (row.userCode+"-"+row.userName)}
                        }},
                    {title : '人工补录量',align : 'center',colspan : _head2colspan2});
            }else if(workType=='5-ForceInput') {
                if($("#endWorkDate").val()>$("#beginWorkDate").val()){
                    _head1colspan1=5;
                    _head2rowspan=2;
                    _head2colspan1=1;
                    _head2colspan2=2;
                    head4Columns.push(forceInputDayBatchNum,forceInputDayWorkload);
                }else{
                    _head1colspan1=9;
                    _head2rowspan=3;
                    _head2colspan1=3;
                    _head2colspan2=6;
                    _head3colspan = 2;
                    head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
                    head4Columns.push(forceInputYearBatchNum,forceInputYearWorkload,forceInputMonthBatchNum,forceInputMonthWorkload,forceInputDayBatchNum,forceInputDayWorkload);
                }
                secondHeadColumns.push({title : '监控中心号',align : 'center',field : 'organCode',rowspan : _head2rowspan},
                    {title : '监控中心名称',align : 'center',field : 'organName',rowspan : _head2rowspan},
                    {title : '操作员',align : 'center',field : 'userCode',rowspan : _head2rowspan,
                        formatter: function (value, row, index) {
                            if((row.userCode+"-"+row.userName)=='小计-:'){return "小计:"}
                            else if((row.userCode+"-"+row.userName)=='合计-:'){return "合计:"}
                            else {return (row.userCode+"-"+row.userName)}
                        }},
                    {title : '二次补录量',align : 'center',colspan : _head2colspan2});
            }else if(workType=='8-Packed') {
                if($("#endWorkDate").val()>$("#beginWorkDate").val()){
                    _head1colspan1=4;
                    _head2rowspan=2;
                    _head2colspan1=1;
                    _head2colspan2=2;
                    head4Columns.push(packedDayWorkload);
                }else{
                    _head1colspan1=6;
                    _head2rowspan=3;
                    _head2colspan1=3;
                    _head2colspan2=6;
                    _head3colspan = 1;
                    head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
                    head4Columns.push(packedYearWorkload,packedMonthWorkload,packedDayWorkload);
                }
                secondHeadColumns.push({title : '监控中心号',align : 'center',field : 'organCode',rowspan : _head2rowspan},
                    {title : '监控中心名称',align : 'center',field : 'organName',rowspan : _head2rowspan},
                    {title : '操作员',align : 'center',field : 'userCode',rowspan : _head2rowspan,
                        formatter: function (value, row, index) {
                            if((row.userCode+"-"+row.userName)=='小计-:'){return "小计:"}
                            else if((row.userCode+"-"+row.userName)=='合计-:'){return "合计:"}
                            else {return (row.userCode+"-"+row.userName)}
                        }},
                    {title : '打包量',align : 'center',colspan : _head2colspan1});
            }else if(workType=='9-InBox') {
                if($("#endWorkDate").val()>$("#beginWorkDate").val()){
                    _head1colspan1=4;
                    _head2rowspan=2;
                    _head2colspan1=1;
                    _head2colspan2=2;
                    head4Columns.push(inBoxDayWorkload);
                }else{
                    _head1colspan1=6;
                    _head2rowspan=3;
                    _head2colspan1=3;
                    _head2colspan2=6;
                    _head3colspan = 1;
                    head3Columns.push({title : '本年',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本月',align : 'center',colspan:_head3colspan});
                    head3Columns.push({title : '本日',align : 'center',colspan:_head3colspan});
                    head4Columns.push(inBoxYearWorkload,inBoxMonthWorkload,inBoxDayWorkload);
                }
                secondHeadColumns.push({title : '监控中心号',align : 'center',field : 'organCode',rowspan : _head2rowspan},
                    {title : '监控中心名称',align : 'center',field : 'organName',rowspan : _head2rowspan},
                    {title : '操作员',align : 'center',field : 'userCode',rowspan : _head2rowspan,
                        formatter: function (value, row, index) {
                        if((row.userCode+"-"+row.userName)=='小计-:'){return "小计:"}
                        else if((row.userCode+"-"+row.userName)=='合计-:'){return "合计:"}
                        else {return (row.userCode+"-"+row.userName)}
                    }},
                    {title : '入箱量',align : 'center',colspan : _head2colspan1});
            }
            //表头汇总
            firstHeadColumns = [{title : firstTitle,align : 'center',colspan : _head1colspan1}];
            if($("#endWorkDate").val()>$("#beginWorkDate").val()){
                headColumns = [
                    firstHeadColumns,
                    secondHeadColumns,
                    head4Columns
                ];
            }else{
                headColumns = [
                    firstHeadColumns,
                    secondHeadColumns,
                    head3Columns,
                    head4Columns
                ];
            }
            $.table.destroy();
            options.url= prefix+"/statistics";
            //options.showExport = true;
            //options.showFooter= true;  //显示合计栏
            options.onLoadSuccess = _mergeCells;
            options.columns = headColumns;
            _initTable(options);
            //
            move();
            //页脚DIV移动
            /*$(".fixed-table-body").on("scroll",function(){
                var sl=this.scrollLeft;
                $(this).next()[0].scrollLeft = sl;
            })*/
        }
        function _rowStyle(row,index){
            var style = {};
            if((row.userCode+"-"+row.userName)=='小计-:'||(row.userCode+"-"+row.userName)=='合计-:'){
                style={css:{'color':'#FF0000'}};
            }
            return style;
        }
        //选择机构
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "00038" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }
        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                layer.close(index);
            }
        }
    </script>
     <script th:inline="javascript">
         function exportData(){
             //导出数据
             $('#bootstrap-table').tableExport({
                 type: 'excel',
                 exportDataType: "all",
                 escape: 'false',
                 exportTypes:['excel'],
                 //ignoreColumn: [0,12],  //忽略某一列的索引
                 fileName: '扫描补录员工作量统计表',  //文件名称设置
                 worksheetName: 'sheet1',  //表格工作区名称
                 tableName: '扫描补录员工作量统计表'
                 //onMsoNumberFormat: doOnMsoNumberFormat,
                 //onCellHtmlData: DoOnCellHtmlData
             });
         }
        function _initTable(options) {
            var defaults = {
                id: "bootstrap-table",
                type: 0, // 0 代表bootstrapTable 1代表bootstrapTreeTable
                height: undefined,
                sidePagination: "server",
                sortName: "",
                sortOrder: "asc",
                pagination: true,
                pageSize: 10,
                pageList: [10, 25, 50],
                toolbar: "toolbar",
                striped: false,
                escape: false,
                firstLoad: true,
                showFooter: false,
                search: false,
                showSearch: true,
                showPageGo: false,
                showRefresh: true,
                showColumns: true,
                showToggle: true,
                showExport: false,
                clickToSelect: false,
                mobileResponsive: true,
                rememberSelected: false,
                fixedColumns: false,
                fixedNumber: 0,
                rightFixedColumns: false,
                rightFixedNumber: 0,
                queryParams: $.table.queryParams,
                rowStyle: {}
            };
            var options = $.extend(defaults, options);
            table.options = options;
            table.config[options.id] = options;
            $.table.initEvent();
            $('#' + options.id).bootstrapTable({
                id: options.id,
                url: options.url,                                   // 请求后台的URL（*）
                contentType: "application/x-www-form-urlencoded",   // 编码类型
                method: 'post',                                     // 请求方式（*）
                cache: false,                                       // 是否使用缓存
                height: options.height,                             // 表格的高度
                striped: options.striped,                           // 是否显示行间隔色
                sortable: true,                                     // 是否启用排序
                sortStable: true,                                   // 设置为 true 将获得稳定的排序
                sortName: options.sortName,                         // 排序列名称
                sortOrder: options.sortOrder,                       // 排序方式  asc 或者 desc
                pagination: options.pagination,                     // 是否显示分页（*）
                pageNumber: 1,                                      // 初始化加载第一页，默认第一页
                pageSize: options.pageSize,                         // 每页的记录行数（*）
                pageList: options.pageList,                         // 可供选择的每页的行数（*）
                firstLoad: options.firstLoad,                       // 是否首次请求加载数据，对于数据较大可以配置false
                escape: options.escape,                             // 转义HTML字符串
                showFooter: options.showFooter,                     // 是否显示表尾
                iconSize: 'outline',                                // 图标大小：undefined默认的按钮尺寸 xs超小按钮sm小按钮lg大按钮
                toolbar: '#' + options.toolbar,                     // 指定工作栏
                sidePagination: options.sidePagination,             // server启用服务端分页client客户端分页
                search: options.search,                             // 是否显示搜索框功能
                searchText: options.searchText,                     // 搜索框初始显示的内容，默认为空
                showSearch: options.showSearch,                     // 是否显示检索信息
                showPageGo: options.showPageGo,               		// 是否显示跳转页
                showRefresh: options.showRefresh,                   // 是否显示刷新按钮
                showColumns: options.showColumns,                   // 是否显示隐藏某列下拉框
                showToggle: options.showToggle,                     // 是否显示详细视图和列表视图的切换按钮
                showExport: options.showExport,                     // 是否支持导出文件
                uniqueId: options.uniqueId,                         // 唯 一的标识符
                clickToSelect: options.clickToSelect,				// 是否启用点击选中行
                mobileResponsive: options.mobileResponsive,         // 是否支持移动端适配
                detailView: options.detailView,                     // 是否启用显示细节视图
                onClickRow: options.onClickRow,                     // 点击某行触发的事件
                onDblClickRow: options.onDblClickRow,               // 双击某行触发的事件
                onClickCell: options.onClickCell,                   // 单击某格触发的事件
                onDblClickCell: options.onDblClickCell,             // 双击某格触发的事件
                onEditableSave: options.onEditableSave,             // 行内编辑保存的事件
                onExpandRow: options.onExpandRow,                   // 点击详细视图的事件
                rememberSelected: options.rememberSelected,         // 启用翻页记住前面的选择
                fixedColumns: options.fixedColumns,                 // 是否启用冻结列（左侧）
                fixedNumber: options.fixedNumber,                   // 列冻结的个数（左侧）
                rightFixedColumns: options.rightFixedColumns,       // 是否启用冻结列（右侧）
                rightFixedNumber: options.rightFixedNumber,         // 列冻结的个数（右侧）
                onReorderRow: options.onReorderRow,                 // 当拖拽结束后处理函数
                queryParams: options.queryParams,                   // 传递参数（*）
                rowStyle: options.rowStyle,                         // 通过自定义函数设置行样式
                columns: options.columns,                           // 显示列信息（*）
                responseHandler: $.table.responseHandler,           // 在加载服务器发送来的数据之前处理函数
                onLoadSuccess: $.table.onLoadSuccess,               // 当所有数据被加载时触发处理函数
                buttonsAlign:"right",  //按钮位置
                exportDataType: "all", //basic', 'all', 'selected'.
                exportTypes:['xlsx','excel','doc'], //导出文件类型
                Icons:'glyphicon glyphicon-export', //导出图标
                exportOptions:{
                    //ignoreColumn: [0,12],  //忽略某一列的索引
                    fileName: '扫描补录员工作量统计表',  //文件名称设置
                    worksheetName: 'sheet1',  //表格工作区名称
                    tableName: '扫描补录员工作量统计表'
                    //onMsoNumberFormat: doOnMsoNumberFormat,
                    //onCellHtmlData: DoOnCellHtmlData,
                },               // 前端导出忽略列索引
                detailFormatter: options.detailFormatter          // 在行下面展示其他数据列表
            });
        }
        //数字
        /*function doOnMsoNumberFormat(cell, row, col){
            var result = "";
            if (row > 0 && col == 0){
                result = "\\@";
            }
            return result;
        }*/
        //处理导出内容,这个方法可以自定义某一行、某一列、甚至某个单元格的内容,也就是将其值设置为自己想要的内容
        /*function DoOnCellHtmlData(cell, row, col, data){
            if(row == 0){
                return data;
            }
            //由于备注列超过6个字的话,通过span标签处理只显示前面6个字,如果直接导出的话会导致内容不完整,因此要将携带完整内容的span标签中title属性的值替换
            if(col == 4 || col ==11 || col == 7){
                var spanObj = $(data);//将带 <span title="val"></span> 标签的字符串转换为jQuery对象
                var title = spanObj.attr("title");//读取<span title="val"></span>中title属性的值
                //var span = cell[0].firstElementChild;//读取cell数组中的第一个值下的第一个元素
                if(typeof(title) != 'undefined'){
                    return title;
                }
            }
            return data;
        }*/
         function _mergeCells(data){
             var data = $('#bootstrap-table').bootstrapTable('getData', true);
             // 合并单元格
             var fieldList=["organCode","organName"];
             mergeCells(data, "organCode", 1, $('#bootstrap-table'),fieldList);
         }
         /**
          * 合并单元格
          *
          * @param data
          *            原始数据（在服务端完成排序）
          * @param fieldName
          *            合并参照的属性名称
          * @param colspan
          *            合并开始列
          * @param target
          *            目标表格对象
          * @param fieldList
          *            要合并的字段集合
          */
         function mergeCells(data,fieldName,colspan,target,fieldList){
        // 声明一个map计算相同属性值在data对象出现的次数和
             var sortMap = {};
             for(var i = 0 ; i < data.length ; i++){
                 for(var prop in data[i]){
                     //例如people.unit.name
                     var fieldArr=fieldName.split(".");
                     getCount(data[i],prop,fieldArr,0,sortMap);
                 }
             }
             var index = 0;
             for(var prop in sortMap){
                 var count = sortMap[prop];
                 for(var i = 0 ; i < fieldList.length ; i++){
                     $(target).bootstrapTable('mergeCells',{index:index, field:fieldList[i], colspan: colspan, rowspan: count});
                 }
                 index += count;
             }
         }
         /**
          * 递归到最后一层 统计数据重复次数
          * 比如例如people.unit.name 就一直取到name
          * 类似于data["people"]["unit"]["name"]
          */
         function getCount(data,prop,fieldArr,index,sortMap){
             if(index == fieldArr.length-1){
                 if(prop == fieldArr[index]){
                     var key = data[prop];
                     if(sortMap.hasOwnProperty(key)){
                         sortMap[key] = sortMap[key]+ 1;
                     } else {
                         sortMap[key] = 1;
                     }
                 }
                 return;
             }
             /*只有一层属性不进行递归
             if(prop == fieldArr[index]){
                 var sdata = data[prop];
                 index=index+1;
                 getCount(sdata,fieldArr[index],fieldArr,index,sortMap);
             }*/
         }
         function move(){
             var div= document.getElementById("_tableDiv");
             var distanceX,distanceY;
             var _move=false;//移动标记
             //按下鼠标时，定义事件
             div.onmousedown =function(evt){
                 evt= evt||window.event;
                 _move=true;
                 //保存鼠标相对于div的偏移量
                 distanceX= evt.clientX;
                 // 按下鼠标时，定义document的移动事件
                 document.onmousemove=function(evt){
                     evt= evt||window.event;
                     if(_move){
                         var moveLeft= evt.clientX- distanceX;
                         $(".fixed-table-body")[0].scrollLeft=$(".fixed-table-body")[0].scrollLeft + moveLeft/10;
                     }
                 }
                 //按下鼠标时，定义document的鼠标弹起事件
                 document.onmouseup= function(){
                     _move=false;
                 }
             }
         }
     </script>
</body>
</html>